home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / edit / tecoc-146.lha / exed.c < prev    next >
C/C++ Source or Header  |  1991-07-05  |  2KB  |  67 lines

  1. /*****************************************************************************
  2.  
  3.     ExeD()
  4.  
  5.     This function executes a D command.
  6.     nD    Delete n characters.
  7.     m,nD    Delete between m and n
  8.  
  9. *****************************************************************************/
  10.  
  11. #include "zport.h"        /* define portability identifiers */
  12. #include "tecoc.h"        /* define general identifiers */
  13. #include "defext.h"        /* define external global variables */
  14. #include "deferr.h"        /* define identifiers for error messages */
  15.  
  16. DEFAULT ExeD()            /* execute a D command */
  17. {
  18.     LONG    Status;
  19.  
  20.     DBGFEN(1,"ExeD",NULL);
  21.  
  22.     if (CmdMod & MARGIS) {            /* if it's m,nD */
  23.         DBGFEX(1,DbgFNm,"ExeK()");
  24.         return ExeK();
  25.     }
  26.  
  27.     if (EStTop == EStBot) {            /* if no numeric argument */
  28.         NArgmt = 1;            /* default is 1D */
  29.     } else {
  30.         UMinus();            /* if it's -D, make it -1D */
  31.         if (GetNmA() == FAILURE) {    /* get numeric argument */
  32.             DBGFEX(1,DbgFNm,"FAILURE");
  33.             return FAILURE;
  34.         }
  35.     }
  36.  
  37.     Status = -1;                    /* -1 means success */
  38.     if (NArgmt > 0) {
  39.         if ((GapEnd+NArgmt) > EBfEnd) {        /* if out of range */
  40.             Status = 0;            /* 0 means failure */
  41.         } else {
  42.             GapEnd += NArgmt;        /* delete */
  43.         }
  44.     } else {
  45.         if ((GapBeg+NArgmt) < EBfBeg) {        /* if out of range */
  46.             Status = 0;            /* 0 means failure */
  47.         } else {
  48.             GapBeg += NArgmt;        /* delete */
  49.         }
  50.     }
  51.     if (CmdMod & COLON) {            /* if it's :D */
  52.         CmdMod = '\0';            /* clear modifiers flags */
  53.         DBGFEX(1,DbgFNm,"PushEx()");
  54.         return PushEx(Status, OPERAND);
  55.     }
  56.  
  57.     if (Status == 0) {
  58.         ErrMsg(ERR_DTB);        /* DTB = "delete too big" */
  59.         DBGFEX(1,DbgFNm,"FAILURE");
  60.         return FAILURE;
  61.     }
  62.  
  63.     CmdMod = '\0';                /* clear modifiers flags */
  64.     DBGFEX(1,DbgFNm,"SUCCESS");
  65.     return SUCCESS;
  66. }
  67.